$(document).ready(function () {
    var flag = false;
    //点击计划展会进入计划展会列表
    $("#content1").click(function () {
        for (var i = 0; i < $(this).attr('class').length; i++) {
            if ($(this).attr('class')[i] == 'ix-content2') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $(this).attr('class', 'ix-content2');
        }
        for (var i = 0; i < $("#content2").attr('class').length; i++) {
            if ($("#content2").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content2").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content3").attr('class').length; i++) {
            if ($("#content3").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content3").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content4").attr('class').length; i++) {
            if ($("#content4").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content4").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content5").attr('class').length; i++) {
            if ($("#content5").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content5").attr('class', 'ix-content1');
        }
        $(".ix-content1-div1-select1").css("display", "none");
        $(".ix-content1-div2-select1").css("display", "block");
        $(".ix-content1-div1-select2").css("display", "block");
        $(".ix-content1-div2-select2").css("display", "none");
        $(".ix-content1-div1-select3").css("display", "block");
        $(".ix-content1-div2-select3").css("display", "none");
        $(".ix-content1-div1-select4").css("display", "block");
        $(".ix-content1-div2-select4").css("display", "none");
        $(".ix-content1-div1-select5").css("display", "block");
        $(".ix-content1-div2-select5").css("display", "none");
        $(".ix-content-bottom .li1").css("display", "block");
        $(".ix-content-bottom .li2").css("display", "none");
        $(".ix-content-bottom .li3").css("display", "none");
        $(".ix-content-bottom .li4").css("display", "none");
        $(".ix-content-bottom .li5").css("display", "none");
        $("#myiframe").attr("src", "plan-exhibition.html");
    });
    //点击会刊中心进入会刊中心页面
    $("#content2").click(function () {
        for (var i = 0; i < $(this).attr('class').length; i++) {
            if ($(this).attr('class')[i] == 'ix-content2') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $(this).attr('class', 'ix-content2');
        }
        for (var i = 0; i < $("#content1").attr('class').length; i++) {
            if ($("#content1").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content1").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content3").attr('class').length; i++) {
            if ($("#content3").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content3").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content4").attr('class').length; i++) {
            if ($("#content4").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content4").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content5").attr('class').length; i++) {
            if ($("#content5").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content5").attr('class', 'ix-content1');
        }
        $(".ix-content1-div1-select1").css("display", "block");
        $(".ix-content1-div2-select1").css("display", "none");
        $(".ix-content1-div1-select2").css("display", "none");
        $(".ix-content1-div2-select2").css("display", "block");
        $(".ix-content1-div1-select3").css("display", "block");
        $(".ix-content1-div2-select3").css("display", "none");
        $(".ix-content1-div1-select4").css("display", "block");
        $(".ix-content1-div2-select4").css("display", "none");
        $(".ix-content1-div1-select5").css("display", "block");
        $(".ix-content1-div2-select5").css("display", "none");
        $(".ix-content-bottom .li1").css("display", "none");
        $(".ix-content-bottom .li2").css("display", "block");
        $(".ix-content-bottom .li3").css("display", "none");
        $(".ix-content-bottom .li4").css("display", "none");
        $(".ix-content-bottom .li5").css("display", "none");
        $("#myiframe").attr("src", "exhibit-list.html");
    });
    //点击个人中心进入个人中心页面
    $("#content3").click(function () {
        for (var i = 0; i < $(this).attr('class').length; i++) {
            if ($(this).attr('class')[i] == 'ix-content2') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $(this).attr('class', 'ix-content2');
        }
        for (var i = 0; i < $("#content1").attr('class').length; i++) {
            if ($("#content1").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content1").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content2").attr('class').length; i++) {
            if ($("#content2").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content2").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content4").attr('class').length; i++) {
            if ($("#content4").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content4").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content5").attr('class').length; i++) {
            if ($("#content5").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content5").attr('class', 'ix-content1');
        }
        $(".ix-content1-div1-select1").css("display", "block");
        $(".ix-content1-div2-select1").css("display", "none");
        $(".ix-content1-div1-select2").css("display", "block");
        $(".ix-content1-div2-select2").css("display", "none");
        $(".ix-content1-div1-select3").css("display", "none");
        $(".ix-content1-div2-select3").css("display", "block");
        $(".ix-content1-div1-select4").css("display", "block");
        $(".ix-content1-div2-select4").css("display", "none");
        $(".ix-content1-div1-select5").css("display", "block");
        $(".ix-content1-div2-select5").css("display", "none");
        $(".ix-content-bottom .li1").css("display", "none");
        $(".ix-content-bottom .li2").css("display", "none");
        $(".ix-content-bottom .li3").css("display", "block");
        $(".ix-content-bottom .li4").css("display", "none");
        $(".ix-content-bottom .li5").css("display", "none");
        $("#myiframe").attr("src", "personal-information.html");
    });
    //点击收藏列表进入收藏列表页面
    $("#content4").click(function () {
        for (var i = 0; i < $(this).attr('class').length; i++) {
            if ($(this).attr('class')[i] == 'ix-content2') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $(this).attr('class', 'ix-content2');
        }
        for (var i = 0; i < $("#content1").attr('class').length; i++) {
            if ($("#content1").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content1").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content2").attr('class').length; i++) {
            if ($("#content2").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content2").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content3").attr('class').length; i++) {
            if ($("#content3").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content3").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content5").attr('class').length; i++) {
            if ($("#content5").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content5").attr('class', 'ix-content1');
        }
        $(".ix-content1-div1-select1").css("display", "block");
        $(".ix-content1-div2-select1").css("display", "none");
        $(".ix-content1-div1-select2").css("display", "block");
        $(".ix-content1-div2-select2").css("display", "none");
        $(".ix-content1-div1-select3").css("display", "block");
        $(".ix-content1-div2-select3").css("display", "none");
        $(".ix-content1-div1-select4").css("display", "none");
        $(".ix-content1-div2-select4").css("display", "block");
        $(".ix-content1-div1-select5").css("display", "block");
        $(".ix-content1-div2-select5").css("display", "none");
        $(".ix-content-bottom .li1").css("display", "none");
        $(".ix-content-bottom .li2").css("display", "none");
        $(".ix-content-bottom .li3").css("display", "none");
        $(".ix-content-bottom .li4").css("display", "block");
        $(".ix-content-bottom .li5").css("display", "none");
        $("#myiframe").attr("src", "collection.html");
    });
    //点击进入商城进入权限购买页面
    $("#content5").click(function () {
        for (var i = 0; i < $(this).attr('class').length; i++) {
            if ($(this).attr('class')[i] == 'ix-content2') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $(this).attr('class', 'ix-content2');
        }
        for (var i = 0; i < $("#content1").attr('class').length; i++) {
            if ($("#content1").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content1").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content2").attr('class').length; i++) {
            if ($("#content2").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content2").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content3").attr('class').length; i++) {
            if ($("#content3").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content3").attr('class', 'ix-content1');
        }
        for (var i = 0; i < $("#content4").attr('class').length; i++) {
            if ($("#content4").attr('class')[i] == 'ix-content1') {
                flag = true;
                return;
            }
        }
        if (flag == false) {
            $("#content4").attr('class', 'ix-content1');
        }
        $(".ix-content1-div1-select1").css("display", "block");
        $(".ix-content1-div2-select1").css("display", "none");
        $(".ix-content1-div1-select2").css("display", "block");
        $(".ix-content1-div2-select2").css("display", "none");
        $(".ix-content1-div1-select3").css("display", "block");
        $(".ix-content1-div2-select3").css("display", "none");
        $(".ix-content1-div1-select4").css("display", "block");
        $(".ix-content1-div2-select4").css("display", "none");
        $(".ix-content1-div1-select5").css("display", "none");
        $(".ix-content1-div2-select5").css("display", "block");
        $(".ix-content-bottom .li1").css("display", "none");
        $(".ix-content-bottom .li2").css("display", "none");
        $(".ix-content-bottom .li3").css("display", "none");
        $(".ix-content-bottom .li4").css("display", "none");
        $(".ix-content-bottom .li5").css("display", "block");
        $("#myiframe").attr("src", "menber-center.html");
    });
    var id;//订单id
    //支付宝支付
    $("#zfb").click(function () {
        id = $("#id").text();
        $.ajax({
            url: "http://www.enet720.net:8080/zwkj/alipay/generateURL/" + id + "",
            type: "GET",
            async: true,//异步请求
            contentType: "application/json;charset=utf-8",
            timeout: 5000,
            success: function (data) {
                if (data.code == "50003") {
                    alert("您已购买！");
                    $("#order").css("display", "none");
                    $(".shade").css("display", "none");
                    $("#myiframe").attr("src", "menber-center.html");
                }
                $("#order-zfb").empty();
                $("#order-zfb").append(data);
            },
            error: function () {
                alert("数据异常请重试！");
            }
        });
    });
    //微信支付
    $("#wx").click(function () {
        id = $("#id").text();
        $.ajax({
            url: "http://www.enet720.net:8080/zwkj/wechart/pay/" + id + "",
            type: "GET",
            async: true,//异步请求
            contentType: "application/json;charset=utf-8",
            timeout: 5000,
            success: function (data) {
                if (data.code == "0") {
                    $('#link_erwei1').empty();//清空
                    //render设置渲染方式 table canvas
                    //typeNumber: -1,  计算模式
                    //correctLevel: 0 纠错等级
                    //background: "#ffffff" 背景颜色
                    //foreground: "#000000" 前景颜色
                    $('#link_erwei1').qrcode({
                        width: 120,
                        height: 120,
                        render: "canvas",
                        correctLevel: 0,
                        background: "#ffffff",
                        foreground: "#000000",
                        text: data.data
                    });  //生成二维码的链接
                    $('#link_erwei').css("display", "block");
                    $("#order").css("display", "none");
                }
                if (data.code == "50003") {
                    alert("您已购买！");
                    $("#order").css("display", "none");
                    $(".shade").css("display", "none");
                    $("#myiframe").attr("src", "menber-center.html");
                }
            },
            error: function () {
                alert("请求超时请重试！");
            }
        });
    });
    //点击订单的关闭按钮
    $("#order-close1").click(function () {
        $(".shade").css("display", "none");
        $('#link_erwei').css("display", "none");
    });
    $("#order-close").click(function () {
        $(".shade").css("display", "none");
        $('#order').css("display", "none");
    });
    var iphone;//手机号
    var password;//密码
    var code;//验证码
    var data = {};//请求参数
    //点击修改密码
    $("#make-sure2").click(function () {
        iphone = $("#ln—text2").val();
        password = $("#ln-password2").val();
        code = $("#ln-yzm3").val();
        if (iphone != null && iphone != "" && iphone != "手机号码") {
            if (code != null && code != "" && code != "输入验证码") {
                if (password != null && password != "" && password != "新密码") {
                    //调用忘记密码接口传的参数
                    data = {
                        "phone": iphone,
                        "npassword": password,
                        "substring": code
                    }
                    //忘记密码接口
                    $.ajax({
                        url: "http://www.enet720.net:8080/zwkj/account/forgetpwd",
                        type: "POST",
                        async: true,//异步请求
                        data: JSON.stringify(data),
                        contentType: "application/json;charset=utf-8",
                        timeout: 5000,
                        success: function (data) {
                            console.log(JSON.stringify(data));
                            if (data.code == "0") {
                                $("#tishi").html("修改成功");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                                $("#wj").css("display", "none");
                                $(".shade").css("display", "none");
                            }
                            if (data.code == "20002") {
                                $("#tishi").html("您输入的账户有误！");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                            }
                            if (data.code == "20003") {
                                $("#tishi").html("您输入的账户已被禁用！");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                            }
                            if (data.code == "20008") {
                                $("#tishi").html("您输入的验证码错误！");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                            }
                            if (data.code == "20013") {
                                $("#tishi").html("您输入的账户尚未注册！");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                            }
                            if(data.code=="20007"){
                                $("#tishi").html("请获取手机验证码！");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                            }
                            if (data.code == "1") {
                                $("#tishi").html("系统繁忙请重试！");
                                $("#tishi").fadeIn(500);
                                $("#tishi").fadeOut(3000);
                            }
                        },
                        error: function () {
                            alert("请求超时请重试！");
                        }
                    });
                } else {
                    $("#tishi").html("请输入新密码");
                    $("#tishi").fadeIn(500);
                    $("#tishi").fadeOut(3000);
                }
            } else {
                $("#tishi").html("请输入验证码");
                $("#tishi").fadeIn(500);
                $("#tishi").fadeOut(3000);
            }
        } else {
            $("#tishi").html("请输入手机号码");
            $("#tishi").fadeIn(500);
            $("#tishi").fadeOut(3000);
        }
    });
    //清楚账号已有数据
    $("#ln—text2").click(function () {
        $(this).val("");
    });
    //手机验证--非空--手机格式验证
    $("#ln—text2").blur(function(){
        var str=$("#ln—text2").val();
        var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
        if(str==""){
            $("#t7").html(" 手机号不能为空！");
            $(this).val("手机号码");
            zt=false;
        }else {
            if(!myreg.test(str)){
                $("#t7").html("手机号格式不正确！");
                zt=false;
            }else {
                $("#t7").html("");
                zt=true;
            }
        }
    });
    //清楚密码已有数据
    $("#ln-password2").click(function () {
        $(this).val("");
        $(this).attr("type","password");
    });
    var zt=false;
    //密码验证---非空验证
    $("#ln-password2").blur(function(){
        if($("#ln-password2").val()==""){
            $("#t9").html(" 新密码不能为空");
            $(this).val("新密码");
            $(this).attr("type","text");
            zt=false;
        }else {
            $("#t9").html("");
            zt=true;
        }
    });
    //清楚验证码已有数据
    $("#ln-yzm3").click(function () {
        $(this).val("");
    });
    //验证码验证
    $("#ln-yzm3").blur(function(){
        if($("#ln-yzm3").val()==""){
            $("#t8").html(" 验证码不能为空");
            $(this).val("输入验证码");
            zt=false;
        }else {
            $("#t8").html("");
            zt=true;
        }
    });
    //修改密码的获取验证码
    $("#btnSendCode1").click(function () {
        sendCode("ln—text2","btnSendCode1");
    });
    var InterValObj; //timer变量，控制时间
    var count = 60; //间隔函数，1秒执行
    var curCount;//当前剩余秒数
    //发送手机验证码
    function sendCode(a,b) {
        iphone=$("#"+a+"").val();
        if(iphone!=null&&iphone!=""&&iphone!="手机号码"){
            $.ajax({
                url:"http://www.enet720.net:8080/zwkj/code/"+iphone+"",
                type:"GET",
                async:true,//异步请求
                contentType: "application/json;charset=utf-8",
                timeout:5000,
                success:function (data) {
                    if(data.code=="0"){
                        curCount = count;
                        //设置button效果，开始计时
                        $("#"+b+"").attr("disabled", "true");
                        $("#"+b+"").val(curCount + "秒后失效");
                        $("#"+b+"").css("background","#666666");
                        InterValObj = window.setInterval(_SetRemainTime(b), 1000); //启动计时器，1秒执行一次
                    }
                    if(data.code=="20011"){
                        $(".tishi").html("请输入正确的手机号");
                        $(".tishi").fadeIn(500);
                        $(".tishi").fadeOut(3000);
                    }
                },
                error:function () {
                    alert("请求超时请重试！");
                }
            });
        }else{
            $(".tishi").html("请输入您的手机号");
            $(".tishi").fadeIn(500);
            $(".tishi").fadeOut(3000);
        }
    }
    //timer处理函数
    function SetRemainTime(b) {
        if (curCount == 1) {
            window.clearInterval(InterValObj);//停止计时器
            $("#"+b+"").removeAttr("disabled");//启用按钮
            $("#"+b+"").val("获取验证码");
            $("#"+b+"").css("background","#EE8E0D");
        }
        else {
            curCount--;
            $("#"+b+"").val(curCount + "秒后失效");
        }
    }
    //创建一个函数，用于返回一个无参数函数
    function _SetRemainTime(b){
        return function(){
            SetRemainTime(b);
        }
    }
});